** Replication materials for "Female Officeholders and Women's Political Engagement: The Role of Parties"
** Analyses of potential contagion effects as explanation for role model effects
** Author: Oscar Castorena
** Data: District-level electoral results compiled by author
**		 (contagion_test.dta)
** Tables replicated with this do file: Tables A12

** Make sure to install estout

* File path of data here
cd "C:\Users\castoro\Documents"

use contagion_test.dta, clear

gen left_strong = 1 if first_12 == "PRD COALITION" | second_12 == "PRD COALITION"
replace left_strong = 0 if first_12 != "PRD COALITION" & second_12 != "PRD COALITION"
lab var left_strong "Left Coalition Winner (t-1)"

gen district_category = 1 if left_strong == 0 & left_woman_12 == 0
replace district_category = 2 if left_strong == 0 & left_woman_12 == 1
replace district_category = 3 if left_strong == 1 & left_woman_12 == 0
replace district_category = 4 if left_strong == 1 & left_woman_12 == 1
lab define morena_dists 0 "Morena Man" 1 "Morena Woman"
lab values morena_woman_15 morena_dists

eststo clear
estpost tab morena_woman_15 district_category

* Contagion effects among left parties (Table A12)
esttab using contagion_test.tex, replace cell(colpct(fmt(2)) b(fmt(g) par keep(Total))) unstack noobs nonumber varwidth(10) modelwidth(15) ///
varlabels(`e(labels)') collabels(none) title("Contagion Effects among Left Parties: Morena 2015 Candidacies"\label{tab:contagionTest}) ///
eqlabels("\shortstack{Left Not\\Competitive\\Male Cand.\\2012}" "\shortstack{Left Not\\Competitive\\Female Cand.\\2012}" "\shortstack{Left\\Competitive\\Male Cand.\\2012}" "\shortstack{Left\\Competitive\\Female Cand.\\2012}") ///
addnotes("Numbers in parentheses indicate total number of districts per column.") 
